#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <vector>

class Bonds {
public:
	Bonds(int,int); //bond length in years; frequency of payments per year
	void setPrincipal(double);
	void setCouponPercent(double);
	void setFrequency(int); //coupons per year -- assume 365 year
	void setYearsToMaturity(int); //assumes 365 day year
	void setfirstCouponDate(int); //in number of days from today
	void compute();
	void printCashFlows();
	double getFairValue(int); //1 = risk-free; 2 = risky
	double getDuration(int); //1 = risk-free; 2 = risky
	double getConvexity(int); //1 = risk-free; 2 = risky
private:
	double principal;
	std::vector<double> cash_date;
	std::vector<double> cash_amount;
	std::vector<double> cash_amount_discounted;
	std::vector<double> cash_amount_discounted_risky;
	double firstCouponDate;
	double couponPercent;
	double time_between_coupons;
	double duration;
	double duration_risky;
	double convexity;
	double convexity_risky;
	double fair_value;
	double fair_value_risky;
	int no_periods;
	int frequency;

};
